/* Name: MuteBtn
 * Name: Tom Dickman
 * Date: 5-3-12
 * Description: A button used to mute sound in game
 * Revisions: See Subversion logs at http://code.google.com/p/software-engineering-2012/source/list
 */

import java.awt.Graphics2D;

public class MuteBtn extends Button {
	private int radius;
	private Sprite sprite;
	
	// Creates a button to mute sound at the given position with the given radius
	public MuteBtn(int px, int py, int pRadius) {
		super(px, py, pRadius);
		Game.create((Item)this, 1000000); // Needed for update, draw, and destroy
		colType = COL_NONE; // Needed for collision checking
		radius = pRadius;
	}
	
	protected void pressed() {
		Sound.mute();
	}
	
	protected void released() {
		Sound.unmute();
	}
	
	// Called every time a new frame is drawn on the screen
	public void draw() {
		Graphics2D gh = Game.getGraphicsHandle();
		if (selected) { // Choose the proper sprite to draw
			sprite = Sprite.load("/sprites/Buttons/mute.png");
		} else {
			sprite = Sprite.load("/sprites/Buttons/unmute.png");
		}
		sprite.draw(gh, x, y);
	}
	
	// Toggles the state of the button - called when clicked
	public void update() {
		if (Sound.isMuted) {
			selected = true;
		} else {
			selected = false;
		}
		updateBtn();
	}
	public void leftMousePress() {leftMousePressBtn();}
	public void leftMouseRelease() {leftMouseReleaseBtn();}
}